package day05;

import java.util.Random;
import java.util.Scanner;

public class MethodDemo2 {
    public static void main(String[] args) {
        int sum = sum(65,45);
        System.out.println(sum);
        System.out.println("输入两个数字：");
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println("和为："+sum(a,b));

        int[] arr1 = generateArray(6,25);
        System.out.println(arr1.length);
        int[] arr2 = generateArray(8,100);
        for (int i = 0; i < arr2.length; i++) {
            System.out.print(arr2[i] + " ");
        }
        scanner.close();
    }

    /**
     * 随机生成len个0-max的随机数
     * @param len
     * @param max
     * @return
     */
    public static int[] generateArray(int len,int max){
        Random random = new Random();
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(max+1);
        }
        return arr;
    }

    /**
     * 两数相加求和
     * @param num1
     * @param num2
     * @return
     */
    public static int sum(int num1,int num2){
        int num = num1+num2;
        return num;
    }
}
